package com.platform.core.web.controller;

import com.platform.comm.web.results.JsonResult;
import com.platform.comm.web.results.PageListJsonResult;
import com.platform.core.service.NcloudSysNotifyUserBiz;
import com.platform.dto.NcloudSysNotifyDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 通知公告
 *
 * @author zq
 */
@Api(tags = "我的公告")
@RestController
@RequestMapping(name = "公告管理", path = "/management/notifyUser")
public class SysNotifyUserController extends BaseController {

    private final NcloudSysNotifyUserBiz sysNotifyUserBiz;

    @Autowired
    public SysNotifyUserController(NcloudSysNotifyUserBiz sysNotifyUserBiz) {
        this.sysNotifyUserBiz = sysNotifyUserBiz;
    }

    /**
     * 分页查询
     */
    @ApiOperation("我的公告")
    @PostMapping(name = "分页查询", path = "/search")
    public PageListJsonResult<NcloudSysNotifyDto> search(@RequestBody Map<String, String> map) {
        Page<NcloudSysNotifyDto> entities = sysNotifyUserBiz.search(map, getPageable(map));
        return new PageListJsonResult<>(entities);
    }

    @PostMapping(name = "修改公告", path = "modify")
    @ApiOperation("修改公告")
    public JsonResult modify(@RequestBody  Map<String,String> params) {
        String status = params.get("status");
        String id = params.get("id");
        sysNotifyUserBiz.modifyStatus(status,id);
        return JsonResult.success();
    }

}
